package multithread;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;

public class ConexaoLembrete extends Thread {
	private Socket s;

	public ConexaoLembrete(Socket s) {
		this.s = s;
	}

	public void run() {
		// Criando o enviar (Send) e receber (Receive) dados
		OutputStream os;
		InputStream is;
		DataInputStream dis;
		DataOutputStream dos;
		try {
			is = s.getInputStream();
			os = s.getOutputStream();
			// Utilizando o Data Imput
			dis = new DataInputStream(is);
			dos = new DataOutputStream(os);
			String nome = dis.readUTF();
			int intervalo = dis.readInt();
			int total= dis.readInt();
			for (int i = 0; i <total; i++) {
				dos.writeUTF("Tomar o "+ nome);
				Thread.sleep(intervalo * 1000);
			}

		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

}
